package com.abbas.abchat.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * Package some of the common api in activity
 */
public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        
        init();
        initEvent();
    }

    /**
     * get layout id for one of activity
     * @return layoutId
     */
    protected abstract int getLayoutId();

    /**
     * on view created do something eg. find widget and init data
     */
    protected abstract void init();

    /**
     * on widget init finished , to add action for some widget
     */
    protected abstract void initEvent();

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    protected void migrateTo(Class clazz){
        startActivity(new Intent(this,clazz));
    }

    protected void showMessage(String msg){
        Toast.makeText(this,msg,Toast.LENGTH_LONG).show();
    }

    protected void finishThis(){
        this.finish();
    }
    
    
}
